<script language="javascript">
	$(document).ready(function(){
		$("#select_s_s").change(function(){
			var this_value=$(this).attr('value');
			//alert(this_value);
			if(this_value=='0')
			{
				$("option[id^='option_w_d_s_']").remove();
				$("#select_w_d_s").hide();
				
			}
			else if(this_value=='w')
			{
				$("option[id^='option_w_d_s_']").remove();
				
				Ajax.call('erp_stock_record.php?act=get_warehousing_style', '' , getWarehousingStyleResponse, 'POST', 'JSON');
				
				function getWarehousingStyleResponse(res)
				{					
					for(var i=0;i<res.warehousing_style.length;i++)
					{
						obj_str='<option id="option_w_d_s_'+res.warehousing_style[i].warehousing_style_id+'" value="'+res.warehousing_style[i].warehousing_style_id+'">';
						obj_str+=res.warehousing_style[i].warehousing_style;
						obj_str+='</option>';
						
						$("#select_w_d_s").append(obj_str);
						$("#select_w_d_s").show();
					}
				}	
			}
			else if(this_value=='d')
			{
				$("option[id^='option_w_d_s_']").remove();
				
				Ajax.call('erp_stock_record.php?act=get_delivery_style', '' , getDeliveryStyleResponse, 'POST', 'JSON');
				
				function getDeliveryStyleResponse(res)
				{					
					for(var i=0;i<res.delivery_style.length;i++)
					{
						obj_str='<option id="option_w_d_s_'+res.delivery_style[i].delivery_style_id+'" value="'+res.delivery_style[i].delivery_style_id+'">';
						obj_str+=res.delivery_style[i].delivery_style;
						obj_str+='</option>';
						
						$("#select_w_d_s").append(obj_str);
						$("#select_w_d_s").show();
					}
				}				
			}
		});
		
		//$("#select_w_d_s").change(function(){
			//var this_id=$(this).attr('value');
			//alert(this_id);
		//});
		
		//$("#select_w_d_s").show();
	});	
</script>


<div class="form-div" style="overflow:hidden;clear:both;width:99%;">
	<div style="float:left;">
	  <form action="erp_warehouse_manage.php" name="searchForm" id="stock_record_search">
	    <input type="hidden" name="act" value="W_D_record" />
		<img src="images/icon_search.gif" width="26" height="22" border="0" alt="SEARCH" />
		
	 	<!-- 收或出库 -->
	    <select name="s_s" id="select_s_s">
	    	<option value="0" {if $stock_style eq 0}selected="selected"{/if}>{$lang.erp_stock_record_search_stock_style_both}</option>
			<option value="w" {if $stock_style eq 'w'}selected="selected"{/if}>{$lang.erp_stock_record_search_stock_style_only_warehousing}</option>
			<option value="d" {if $stock_style eq 'd'}selected="selected"{/if}>{$lang.erp_stock_record_search_stock_style_only_delivery}</option>
		</select>   
	
	    <!-- 出入库类型 -->
	    <select name="w_d_s_id" style="display:none;" id="select_w_d_s">
			<option value="0">{$lang.erp_stock_record_search_w_d_style}</option>
		</select>
		
		<!-- 收发货仓库 -->
	    <select name="w_id" id="w_id">
	    	<option value="0" {if $warehouse_id eq 0}selected="selected"{/if} >{$lang.erp_stock_record_search_warehouse}</option>
			{foreach from=$warehouse_info item=warehouse_info}
				<option value="{$warehouse_info.warehouse_id}" {if $warehouse_id eq $warehouse_info.warehouse_id}selected="selected"{/if}>--{$warehouse_info.name}</option>
			{/foreach}
		</select>
	
	    <!-- 起始期 -->
	    {$lang.erp_stock_record_search_start_date} <input size="10" type="text" name="s_date" size="15" id="s_date" value="{$start_date}" />
		
		<!-- 结束期 -->
	    {$lang.erp_stock_record_search_end_date} <input size="10" type="text" name="e_date" size="15" id="e_date" value="{$end_date}" />
	
		<!-- 产品货号 -->
	    {$lang.erp_stock_record_search_goods_sn} <input size="10" type="text" name="goods_sn" size="15" id="goods_sn" value="{$goods_sn}" />
		
	    <input type="submit" value="{$lang.button_search}" class="button" />
	  </form>
  	</div>
  
	<div style="float:right;">
		<img id="print_w_d_record" src="images/print.gif" />
	</div>
	
	<div style="float:right; margin-right:10px;">
		<img id="export_w_d_record" src="images/export.gif" />
	</div> 
  
</div>

<script language="javascript">	
$(document).ready(function(){
	
	$("#print_w_d_record").css('cursor','pointer');
	$("#print_w_d_record").click(function(){
		
		var goods_sn=$("#goods_sn").attr('value');
		var s_date=$("#s_date").attr('value');
		var e_date=$("#e_date").attr('value');
		var w_id=$("#w_id").attr('value');
		var w_d_s_id=$("#select_w_d_s").attr('value');
		var s_s=$("#select_s_s").attr('value');
	
		var url="erp_warehouse_manage.php?act=print_W_D_record&goods_sn="+goods_sn+"&s_date="+s_date+"&e_date="+e_date+"&w_id="+w_id+"&w_d_s_id="+w_d_s_id+"&s_s="+s_s;
		
		window.open(url);	
	});
	
	$("#export_w_d_record").css('cursor','pointer');
	$("#export_w_d_record").click(function(){


		var goods_sn=$("#goods_sn").attr('value');
		var s_date=$("#s_date").attr('value');
		var e_date=$("#e_date").attr('value');
		var w_id=$("#w_id").attr('value');
		var w_d_s_id=$("#select_w_d_s").attr('value');
		var s_s=$("#select_s_s").attr('value');
	
		var url="erp_warehouse_manage.php?act=export_W_D_record&goods_sn="+goods_sn+"&s_date="+s_date+"&e_date="+e_date+"&w_id="+w_id+"&w_d_s_id="+w_d_s_id+"&s_s="+s_s;
		
		Ajax.call(url, '' , exportStockRecordResponse, 'POST', 'JSON');
		
		function exportStockRecordResponse(res)
		{
			if(res.error!=0)
			{
				alert(res.message);
			}
			else{
				//alert(res.url);
				window.location=res.url;	
			}
		}
	});	
	
});

</script>

